package org.finesys.chat.core.base.document.splitter;

import org.finesys.chat.core.base.document.tokenizer.Tokenizer;

public class DocumentByWordSplitter extends HierarchicalDocumentSplitter{

    public DocumentByWordSplitter(int maxSegmentSizeInChars, int maxOverlapSizeInChars) {
        super(maxSegmentSizeInChars, maxOverlapSizeInChars, (Tokenizer)null, (DocumentSplitter)null);
    }

    public DocumentByWordSplitter(int maxSegmentSizeInChars, int maxOverlapSizeInChars, DocumentSplitter subSplitter) {
        super(maxSegmentSizeInChars, maxOverlapSizeInChars, (Tokenizer)null, subSplitter);
    }

    public DocumentByWordSplitter(int maxSegmentSizeInTokens, int maxOverlapSizeInTokens, Tokenizer tokenizer) {
        super(maxSegmentSizeInTokens, maxOverlapSizeInTokens, tokenizer, (DocumentSplitter)null);
    }

    public DocumentByWordSplitter(int maxSegmentSizeInTokens, int maxOverlapSizeInTokens, Tokenizer tokenizer, DocumentSplitter subSplitter) {
        super(maxSegmentSizeInTokens, maxOverlapSizeInTokens, tokenizer, subSplitter);
    }

    public String[] split(String text) {
        return text.split("\\s+");
    }

    public String joinDelimiter() {
        return " ";
    }

    protected DocumentSplitter defaultSubSplitter() {
        return new DocumentByCharacterSplitter(this.maxSegmentSize, this.maxOverlapSize, this.tokenizer);
    }
}
